DATA_FILE = 'data.txt'
DATA_SIZE = 100

def generate_data
  rand(2_000_000_000) - 1_000_000_000
end

def datafile
  __FILE__.sub /[^ \/]+$/, DATA_FILE
end

def func
  f = File.new(datafile,  "a")

  DATA_SIZE.times do
    f.write "#{generate_data}\n"
  end
rescue => e
  puts e.message
  puts e.backtrace
ensure
  f.close
end

func
